<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>知识传播-tarqat.com</title>
	<link rel="shortcut icon" href="tpl/img/favicon.ico" />
	<link rel="stylesheet" href="tpl/css/commun.css" />
	<link rel="stylesheet" href="tpl/css/reg.css" />
    <script type="text/javascript" src="tpl/js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        $(function(){
            var name;
            var password;
            var r_password;
            var email;
            var check;
            var name_t;


            //   提交判断
            $("form").submit(function(){
                if(name_t==1){
                    alert("用户名已存在");
                    return false;
                }
                if($("input[name=username]").val()==""){
                    alert("用户名不能为空");
                    return false;
                }
                if($("input[name=password]").val()!="" && $("input[name=r_password]").val()!=""){
                    var password_val=$("input[name=password]").val();
                    var r_password_val=$("input[name=r_password]").val();
                    if(password_val==r_password_val){
                        check=1;
                    }else{
                        alert("密码不配");
                        check=0;
                        return false;
                    }
                }
                if($("input[name=password]").val()==""){
                    alert("密码不能为空");
                    return false;
                }
                if($("input[name=r_password]").val()==""){
                    alert("请确认密码");
                    return false;
                }
                if($("input[name=email]").val()==""){
                    alert("邮箱不能为空");
                    return false;
                }
                if(password==1 && r_password==1 && email==1 && check==1 && name_t==0){
                    return true;
                }
                return false;
            });
            //            密码，名字
            $("input[name=password]").blur(function(){
                var password_val=$("input[name=password]").val();
                if(password_val==""){
                    $("input[name=password]").css({boxShadow:"#f94d30 0px 0px 2px inset"});
                    password=0;
                }else{
                    $("input[name=password]").css({boxShadow:"#26BA60 0px 0px 2px inset"});
                    password=1;
                }
            });

            $("input[name=r_password]").blur(function(){
                var r_password_val=$("input[name=r_password]").val();
                if(r_password_val==""){
                    $("input[name=r_password]").css({boxShadow:"#f94d30 0px 0px 2px inset"});
                    r_password=0;
                }else{
                    $("input[name=r_password]").css({boxShadow:"#26BA60 0px 0px 2px inset"});
                    r_password=1;
                }
            });

            $("input[name=email]").blur(function(){
                var email_val=$("input[name=email]").val();
                if(email_val==""){
                    $("input[name=email]").css({boxShadow:"#f94d30 0px 0px 2px inset"});
                    email=0;
                }else{
                    $("input[name=email]").css({boxShadow:"#26BA60 0px 0px 2px inset"});
                    email=1;
                }
            });

            //  用户名
            $("input[name=username]").blur(function(){
                var name=$("input[name=username]").val();
                if(name==""){
                    $("input[name=username]").css({boxShadow:"#f94d30 0px 0px 2px inset"});
                }else{
                    $.ajax({
                        type:"post",
                        url:"index.php?c=Member&a=check_name",
                        data:{name:name},
                        dataType:"text",
                        success:function(result){
                            console.log(result);
                            if(result){
                                $("input[name=username]").css({boxShadow:"#f94d30 0px 0px 2px inset"});
                                name_t=1;
                            }else{
                                $("input[name=username]").css({boxShadow:"#26BA60 0px 0px 2px inset"});
                                name_t=0;
                            }
                        }
                    });
                }
            });

        })
    </script>
</head>
<body>
	<div id="box">
		<div class="logo">
            <a href="index.php"><img src="tpl/img/tarqat_logo.png" alt="" /></a>
		</div>
		<div class="form">
			<form action="" method="post">
				<ul> 
					<li id="first"><input type="text" name="username" placeholder="请输入用户名" /></li>
					<li><input type="password" name="password" placeholder="请输入密码" /></li>
					<li><input type="password" name="r_password" placeholder="请确认密码" /></li>
					<li><input type="text" name="email" placeholder="请输入邮箱" /></li>
					<li id="sub"><input type="submit" value="提交" /></li>
				</ul>
			</form>
		</div>
	</div>
</body>
</html>